FROM golang:1.17-alpine as builder
WORKDIR /go/src/github.com/suyghur/ci-go-demo/service1
ARG ARCH="amd64"
ARG OS="linux"
COPY . .
COPY go.mod .
RUN go env -w GOPROXY=https://goproxy.cn,direct
RUN go env
RUN go get && \
    CGO_ENABLED=0 GOOS=linux go build -a -installsuffix cgo -o main .

FROM alpine:latest
WORKDIR /root/
COPY --from=builder /go/src/github.com/suyghur/ci-go-demo/service1/ .
CMD [ "./main" ]